﻿using System;
using System.Configuration;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SchEduApp
{

    public sealed class AlgorithmConfigurationSection : ConfigurationSection
    {
        public AlgorithmConfigurationSection()
        {
        }
        [ConfigurationProperty("algorithmMenuItems", IsDefaultCollection = true)]
        public AlgorithmMenuItemCollection AlgorithmMenuItems
        {
            get
            {
                return (AlgorithmMenuItemCollection)base["algorithmMenuItems"];
            }
        }
    }
    public sealed class AlgorithmMenuItemCollection : ConfigurationElementCollection
    {
        protected override ConfigurationElement CreateNewElement()
        {
            return new AlgorithmMenuItem();
        }
        protected override object GetElementKey( ConfigurationElement element )
        {
            return ((AlgorithmMenuItem)element).Name;
        }
        public override ConfigurationElementCollectionType CollectionType
        {
            get
            {
                return ConfigurationElementCollectionType.BasicMap;
            }
        }
        protected override string ElementName
        {
            get
            {
                return "algorithmMenuItem";
            }
        }
        public AlgorithmMenuItem this[int index]
        {
            get
            {
                return (AlgorithmMenuItem)BaseGet(index);
            }
            set
            {
                if (BaseGet(index) != null)
                {
                    BaseRemoveAt(index);
                }
                BaseAdd(index, value);
            }
        }


    }
    public sealed class AlgorithmMenuItem : ConfigurationElement
    {
        [ConfigurationProperty( "name", IsKey = true, IsRequired = true )]
        public string Name
        {
            get
            {
                return (string)base[ "name" ];
            }
            set
            {
                base[ "name" ] = value;
            }
        }
        [ConfigurationProperty("class", IsRequired = false)]
        public string Class
        {
            get
            {
                return (string)base["class"];
            }
            set
            {
                base["class"] = value;
            }
        }
        [ConfigurationProperty("assembly", IsRequired = false)]
        public string Assembly
        {
            get
            {
                return (string)base["assembly"];
            }
            set
            {
                base["assembly"] = value;
            }
        }

        [ConfigurationProperty("algorithmMenuItems", IsDefaultCollection = true)]
        public AlgorithmMenuItemCollection AlgorithmMenuItems
        {
            get
            {
                return (AlgorithmMenuItemCollection)base["algorithmMenuItems"];
            }
        }

    }
  
}

 